/*
 * Created on 2005-9-22
 * Author: Liao Xuefeng, asklxf@163.com
 * Copyright (C) 2005, Liao Xuefeng.
 */
package com.javaeedev.example.thread;

import java.util.*;

public class TaskQueue {

    private List queue = new LinkedList();

    public synchronized Task getTask() {
        while(queue.size()==0) {
            try {
                this.wait();
            }
            catch(InterruptedException ie) {
                return null;
            }
        }
        return (Task)queue.remove(0);
    }

    public synchronized void putTask(Task task) {
        queue.add(task);
        this.notifyAll();
    }

}
